package com.yaoxiaoqing.objectclass;

import java.util.Scanner;

public class AverageScore {
    public static void main(String[] args) {
        System.out.println("当前得分"+getAverageScore());
    }

    public static double getAverageScore() {
//        if(num<=2){
//            System.out.println("评委人数必须大于2人,请重新输入");
//            return
//        }
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入评委人数");
        int number= sc.nextInt();
        int[] scores = new int[number];



        for (int i = 0; i < scores.length; i++) {
            System.out.println("请输入第" + (i + 1) + "位评委的分数");
            scores[i]= sc.nextInt();
        }
        double min = scores[0];
        double max = scores[0];
        double total = 0;
        for (int i = 0; i < scores.length; i++) {
            total += scores[i];
            min = Math.min(min, scores[i]);
            max = Math.max(max, scores[i]);
        }

       return 1.0*(total-min-max)/(number-2);

    }
}
